OpenBuildings GenerativeComponents Help

Automatic Replication

Automatic replication is a distinguishing aspect of GCScript, and one of its most powerful aspects.

Automatic replication can be described as: Generally, wherever a single value is expected, a list of values of that same type can be provided, instead.

Example

int n = 11
n * 4                    
  // This results in the single value, 44.
n = {11, 100, -2}
n * 4                    
  // This results in the list, {44, 400, -8}.

Of course, the list doesn't need to be a literal list, with curly braces. It can be any value that results in a list, such as the name of another variable that contains a list, or a call to a function that returns a list:

Example

int myList = {11, 100, -2}
n = myList
n * 4                    
  // This results in the list, {44, 400, -8}.
n = Series(1, 6, 1);       
// This call to the Series function returns the list, {1,2,3,4,5,6}.
n * 4                      
// This results in the list, {4, 8, 12, 16, 20, 24}.